/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GodK
 * Date: 2024-03-13
 * Time: 15:46
 */
public class Main {
    /*class Solution {
    public static boolean isValidChar(char ch){
        if((ch >= 'a' && ch <= 'z') ||
                (ch >= 'A' && ch <= 'Z')){
            return true;
        }
        return false;
    }
    public static int countSegments(String s) {
            int count = 0;
            int i = 0;
            while(i<s.length()) {
                while(i<s.length()&&!isValidChar(s.charAt(i))){
                    i++;
                }
                count++;
                while(i<s.length()&&isValidChar(s.charAt(i))){
                i++;
             }
         }
            return count;
        }
    }

    public static void main(String[] args) {
        String s = "Hello, my name is John";
        int ret = Solution.countSegments(s);
        System.out.println(ret);
    }
     */
    class Solution {
        public static int countSegments(String s) {
            int count = 0;
            int i = 0;
            while (i < s.length()) {
                while (i < s.length() && s.charAt(i) != ' ') {
                    i++;
                }
                count++;
                i++;
            }
            return count;
        }
    }

    public static void main(String[] args) {
        String s = "Hello, my name is John";
        int ret = Solution.countSegments(s);
        System.out.println(ret);
    }
}
